﻿using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Text;

namespace Allegro.MathInterface
{
    /// <summary>
    /// Function delegate
    /// </summary>
    /// <param name="x"></param>
    /// <returns></returns>
    public delegate double Function(double x);

    /// <summary>
    /// Parametric function delegate
    /// </summary>
    /// <param name="x"></param>
    /// <param name="parameters"></param>
    /// <returns></returns>
    public delegate double ParametricFunction(double x, double[] parameters);

    /// <summary>
    /// Delegate for a function taking a vector argument
    /// </summary>
    /// <param name="x"></param>
    /// <returns></returns>
    public delegate double VectorFunction(double[] x);

    /// <summary>
    /// Delegate for a parametric function taking a vector argument
    /// </summary>
    /// <param name="x"></param>
    /// <param name="parameters"></param>
    /// <returns></returns>
    public delegate double ParametricVectorFunction(double[] x, double[] parameters);

    /// <summary>
    /// Map of a vector to another vector
    /// </summary>
    /// <param name="x"></param>
    /// <param name="result"></param>
    public delegate void VectorMap(double[] x, double[] result);

    /// <summary>
    /// Delegate for mapping a vector to a matrix
    /// </summary>
    /// <param name="x"></param>
    /// <param name="j"></param>
    public delegate void VectorMatrixMap(double[] x, double[,] j);

    /// <summary>
    /// Parametric map of a vector to another vector
    /// </summary>
    /// <param name="x"></param>
    /// <param name="result"></param>
    /// <param name="parameters"></param>
    public delegate void ParametricVectormap(double[] x, double[] result, double[] parameters);


    public interface IParametricFunction
    {
        /// <summary>
        ///  Parameter values
        /// </summary>
        double[] Parameters { get; set; }

        /// <summary>
        /// Function value
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        double Value(double x);
    }
    public interface IParametricVectorFunction
    {
        /// <summary>
        ///  Parameter values
        /// </summary>
        double[] Parameters { get; set; }

        /// <summary>
        /// Function value
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        double Value(double[] x);
    }

    /// <summary>
    /// Interface implemented by a numerical function integrator
    /// </summary>
    public interface IFunctionIntegrator
    {
        /// <summary>
        /// Return the integral of the function f from a to b.
        /// </summary>
        /// <param name="f"></param>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        double Integrate(Func<double, double> f, double a, double b);
    }
    /// <summary>
    /// Interface for iterative integration, e.g. Simpson, Romberg methods
    /// </summary>
    public interface IIterativeFunctionIntegrator : IFunctionIntegrator
    {
        /// <summary>
        /// Tolerance of the integration
        /// </summary>
        double Tolerance { get; set; }
    }
}
